﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ConfigurationManager.View
{
    public partial class frmMain : Form
    {
        public frmMain()
        {
            InitializeComponent();

            try
            {
                ConfigurationManager.DataAccess.Product p = new ConfigurationManager.DataAccess.Product();
                ConfigurationManager.DataAccess.Instance i = new ConfigurationManager.DataAccess.Instance();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Atenção");
            }
        }

        private void sairToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void produtoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmProductList frm = new frmProductList();
            frm.MdiParent = this;
            frm.Show();
        }

        private void instanciaToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //abrir cadastro de instancias
            frmInstanceList frm = new frmInstanceList();
            frm.MdiParent = this;
            frm.Show();
        }

        private void processoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //abrir cadastro de processos
            frmProcessList frm = new frmProcessList();
            frm.MdiParent = this;
            frm.Show();
        }

        private void exportarToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            //abrir tela de exportacao
            frmExport frm = new frmExport();
            frm.MdiParent = this;
            frm.WindowState = FormWindowState.Normal;
            frm.Show();
        }

        private void inteligenceModulesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmInteligenceModuleList frm = new frmInteligenceModuleList();
            frm.MdiParent = this;
            frm.Show();
        }

        private void restaurarTodasToolStripMenuItem_Click(object sender, EventArgs e)
        {
            foreach (Form f in this.MdiChildren)
                f.WindowState = FormWindowState.Normal;
        }

        private void maximizarTodasToolStripMenuItem_Click(object sender, EventArgs e)
        {
            foreach (Form f in this.MdiChildren)
                f.WindowState = FormWindowState.Maximized;
        }

        private void minimizarTodasToolStripMenuItem_Click(object sender, EventArgs e)
        {
            foreach (Form f in this.MdiChildren)
                f.WindowState = FormWindowState.Minimized;
        }

        private void fecharTodasToolStripMenuItem_Click(object sender, EventArgs e)
        {
            foreach (Form f in this.MdiChildren)
                f.Close();
        }

        private void janelasToolStripMenuItem_MouseDown(object sender, MouseEventArgs e)
        {
            bool hasChildren = this.MdiChildren.Length > 0;
            restaurarTodasToolStripMenuItem.Enabled = hasChildren;
            maximizarTodasToolStripMenuItem.Enabled = hasChildren;
            minimizarTodasToolStripMenuItem.Enabled = hasChildren;
            fecharTodasToolStripMenuItem.Enabled = hasChildren;
        }
    }
}
